<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Three.js Plugin Test</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            font-family: Arial, sans-serif;
            background: #1a1a1a;
            color: white;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .header {
            text-align: center;
            margin-bottom: 30px;
        }
        
        .demo-section {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .demo-container {
            background: #2a2a2a;
            border-radius: 8px;
            padding: 20px;
            border: 1px solid #444;
        }
        
        .demo-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 15px;
            color: #00ff88;
        }
        
        #three-container {
            width: 100%;
            height: 400px;
            border: 2px solid #444;
            border-radius: 4px;
            background: #000;
        }
        
        .controls {
            margin-top: 15px;
        }
        
        .btn {
            background: #007acc;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
            margin: 5px;
        }
        
        .btn:hover {
            background: #005a9e;
        }
        
        .info {
            background: #333;
            padding: 15px;
            border-radius: 4px;
            margin-top: 20px;
        }
        
        .code-example {
            background: #1e1e1e;
            padding: 15px;
            border-radius: 4px;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            overflow-x: auto;
            margin-top: 15px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🧪 Three.js Plugin Test</h1>
            <p>测试 @code-editor/three 插件的功能</p>
        </div>
        
        <div class="demo-section">
            <div class="demo-container">
                <div class="demo-title">3D 场景演示</div>
                <div id="three-container"></div>
                <div class="controls">
                    <button class="btn" onclick="addBox()">添加立方体</button>
                    <button class="btn" onclick="addSphere()">添加球体</button>
                    <button class="btn" onclick="clearObjects()">清空场景</button>
                </div>
            </div>
            
            <div class="demo-container">
                <div class="demo-title">插件信息</div>
                <div class="info">
                    <p><strong>插件名称:</strong> @code-editor/three</p>
                    <p><strong>版本:</strong> 1.0.0</p>
                    <p><strong>功能:</strong></p>
                    <ul>
                        <li>基础3D场景管理</li>
                        <li>相机控制</li>
                        <li>GUI界面</li>
                        <li>几何体创建工具</li>
                        <li>光源管理</li>
                    </ul>
                </div>
                
                <div class="code-example">
// 使用示例
import { Base } from '@code-editor/three'
import { createBox, addLight } from '@code-editor/three'

class MyDemo extends Base {
  renderContent() {
    const box = createBox(2, 2, 2, 0x00ff00)
    this.scene.add(box)
  }
}

const demo = new MyDemo()
demo.init(container)
                </div>
            </div>
        </div>
    </div>

    <script type="importmap" src="/importmap.json"></script>
    <script type="module">
        import ThreeDemo from './three-demo.js'
        
        let demoInstance = null
        
        // 初始化
        window.addEventListener('load', () => {
            const container = document.getElementById('three-container')
            demoInstance = new ThreeDemo()
            demoInstance.init(container)
            
            console.log('✅ Three.js Plugin loaded successfully!')
        })
        
        // 全局控制函数
        window.addBox = () => {
            if (demoInstance) {
                demoInstance.addBox()
            }
        }
        
        window.addSphere = () => {
            if (demoInstance) {
                demoInstance.addSphere()
            }
        }
        
        window.clearObjects = () => {
            if (demoInstance) {
                demoInstance.clearObjects()
            }
        }
    </script>
</body>
</html> 